package algorithm.sort;

/**
 * 冒泡排序
 */
public class BubbleSort {

    public int[] sortArray(int[] nums){
        if (nums.length  == 0){
            return nums;
        }
        //循环数组长度的次数
        for ( int i = 0 ; i < nums.length ; i++  ){
            for( int j = 0; j < nums.length - 1 - i ; j++ ){
                if (nums[j+1] < nums[j]){
                   int temp = nums[j + 1];
                   nums[j + 1] = nums[j];
                   nums[j] = temp;
                }
            }
        }

        return nums;
    }
}
